﻿using System;
using ExFlash.Records;

namespace ExFlash.Actions
{
    public class ActionConstantPool : ActionRecord
    {
        private readonly int _swfVersion;

        public ushort Count
        {
            get;
            protected set;
        }

        public StringRecord[] ConstantPool
        {
            get;
            protected set;
        }

        public ActionConstantPool(ushort len, int version)
            : base((byte)ActionCodes.ActionConstantPool, len)
        {
            _swfVersion = version;
        }

        public override void SwfDeserialize(BinaryBitReader reader)
        {
            Count = reader.ReadUInt16();

            ConstantPool = new StringRecord[Count];

            for (int i = 0; i < Count; i++)
            {
                ConstantPool[i] = new StringRecord(_swfVersion);
                ConstantPool[i].SwfDeserialize(reader);
            }
        }

        public override void SwfSerialize(byte[] arr, ref int offset)
        {
            throw new NotImplementedException();
        }
    }
}
